#include<bits/stdc++.h>
#define int long long
#define fff(i,l,r) for(int i=l;i<=r;i++)
#define ddd(i,l,r) for(int i=l;i>=r;i--)
using namespace std;
const int N=1e5+5;
int n,m,l,v;
struct car{
    double d;
    int v;
    int a;
}b[N];
int p[N];
bool t1p=1,t2p=1;
const double eps=1e-5;
set<int> se;
void solve(){
    t1p=1;
    t2p=1;
    cin>>n>>m>>l>>v;
    fff(i,1,n){
        cin>>b[i].d>>b[i].v>>b[i].a;
        if(b[i].a!=0)t1p=0;
        if(b[i].a<0)t2p=0;
    }
    int maxn=-1;
    fff(i,1,m)cin>>p[i],maxn=max(maxn,p[i]);
    if(t1p){
        int ans1=0,ans2;
        fff(i,1,n){
            if(b[i].d<=maxn&&b[i].v>v)ans1++;
        }
        ans2=m-1;
        if(ans1==0)ans2++;
        cout<<ans1<<' '<<ans2<<'\n';
        return;
    }
    if(t2p){
        int ans1=0,ans2;
        fff(i,1,n){
            if(b[i].v>v){
                if(maxn>=b[i].d)ans1++;
            }
            else if(maxn*1.0000>=b[i].d*1.000+(v*v-b[i].v*b[i].v)/2/b[i].a+eps)ans1++;
            // else cout<<maxn<<' '<<fixed<<setprecision(5)<<double(b[i].d*1.000+b[i].csd*1.000)<<'\n';
        }
        ans2=m-1;
        if(ans1==0)ans2++;
        cout<<ans1<<' '<<ans2<<'\n';
        return;
    }
    int ans1=0,ans2;
    fff(i,1,n){
        fff(j,1,m){
         if(b[i].d<=p[j]){ans1++;se.insert(j);break;}
        }
    }
    cout<<ans1<<' '<<m-se.size()<<'\n';
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--)solve();
    return 0;
}